package com.whty.cms.filewps.common.model;

import com.whty.cms.filewps.common.constants.Consts;
import com.whty.cms.filewps.upload.dto.AttachFile;

import java.util.Date;

public class EsAttachment {
	
	private Long fid;                 //文件id
    private String fileName;          //文件名称
    private String fileMd5;           //文件MD5值
    private Long fileLength;          //文件字节长度
    private String fileSize;          //文件大小 带单位的KB  MB  GB
    private String fileExt;           //文件格式 如pdf  MP4
    private String userId;            //上传用户id
    private Date postedTime;          //上传时间
    private String status;            //状态   1 上传完成
    private String filePath;          //文件路径   也是coskey
    private String sourceType;        //文件来源
    private String yunType;           //文件存储类型   1腾讯云  后期扩展到其他云
    private String platformCode;      //文件的平台编码
    private String applyType;         //上传文件的应用类型
    private String uploadId;          //上传的uploadId
    private String fileExtType;       //文件格式类型   doc  pic  audio   video
    private String transFileLength;   //转码后文件大小
    private String downloadUrl;       //文件下载地址
    private String previewUrl;        //文件预览地址
    private String bucketName;        //文件所属bucketName
    private String transformStutas;   //文件转码状态  0转码中   1转码完成   2转码失败
    private String transformId;       //文件转码id
    private String thumbnailId;       //缩略图任务id
    private String duration;          //视频时长
    private String thumbnailUrl;      //缩略图地址
    
    
	public EsAttachment() {
		
	}
	
	public EsAttachment(AttachFile attachFile) {
		this.fid = attachFile.getFid();
		this.fileName = attachFile.getFileName();
		this.fileMd5 = attachFile.getFileMd5();
		this.fileLength = attachFile.getFileLength();
		this.fileSize = attachFile.getFileSize();
		this.fileExt = attachFile.getFileExt();
		this.userId = attachFile.getUserId();
		this.postedTime = attachFile.getPostedTime();
		this.status = attachFile.getStatus();
		this.filePath = attachFile.getFilePath();
		this.sourceType = attachFile.getSourceType();
		this.yunType = attachFile.getYunType();
		this.platformCode = attachFile.getPlatformCode();
		this.applyType = attachFile.getApplyType();
		this.uploadId = attachFile.getUploadId();
		this.transformId = attachFile.getTransformId();
		this.thumbnailId = attachFile.getThumbnailId();
	}


	public EsAttachment(Long fid, String fileName, String fileMd5, Long fileLength, String fileSize, String fileExt,
                        String userId, Date postedTime, String status, String filePath, String sourceType, String yunType,
                        String platformCode, String applyType, String uploadId, String fileExtType, String downloadUrl,
                        String previewUrl, String bucketName, String transformStutas, String transformId, String duration,
                        String thumbnailUrl, String transFileLength, String thumbnailId) {
		super();
		this.fid = fid;
		this.fileName = fileName;
		this.fileMd5 = fileMd5;
		this.fileLength = fileLength;
		this.fileSize = fileSize;
		this.fileExt = fileExt;
		this.userId = userId;
		this.postedTime = postedTime;
		this.status = status;
		this.filePath = filePath;
		this.sourceType = sourceType;
		this.yunType = yunType;
		this.platformCode = platformCode;
		this.applyType = applyType;
		this.uploadId = uploadId;
		this.fileExtType = fileExtType;
		this.downloadUrl = downloadUrl;
		this.previewUrl = previewUrl;
		this.bucketName = bucketName;
		this.transformStutas = transformStutas;
		this.transformId = transformId;
		this.duration = duration;
		this.thumbnailUrl = thumbnailUrl;
		this.transFileLength = transFileLength;
		this.thumbnailId = thumbnailId;
	}


	public Long getFid() {
		return fid;
	}


	public void setFid(Long fid) {
		this.fid = fid;
	}


	public String getFileName() {
		return fileName;
	}


	public void setFileName(String fileName) {
		this.fileName = fileName;
	}


	public String getFileMd5() {
		return fileMd5;
	}


	public void setFileMd5(String fileMd5) {
		this.fileMd5 = fileMd5;
	}


	public Long getFileLength() {
		return fileLength;
	}


	public void setFileLength(Long fileLength) {
		this.fileLength = fileLength;
	}


	public String getFileSize() {
		if (fileLength < 1024) {
			return String.valueOf(fileLength) + "B";
		} else {
			fileLength = fileLength / 1024;
		}
		if (fileLength < 1024) {
		    return String.valueOf(fileLength) + "KB";
		} else {
			fileLength = fileLength / 1024;
		}
		if (fileLength < 1024) {
			fileLength = fileLength * 100;
		    return String.valueOf((fileLength / 100)) + "."
		        + String.valueOf((fileLength % 100)) + "MB";
		} else {
			fileLength = fileLength * 100 / 1024;
		    return String.valueOf((fileLength)) + "."
		        + String.valueOf((fileLength % 100)) + "GB";
		}
	}


	public void setFileSize(String fileSize) {
		this.fileSize = fileSize;
	}


	public String getFileExt() {
		return fileExt;
	}


	public void setFileExt(String fileExt) {
		this.fileExt = fileExt;
	}


	public String getUserId() {
		return userId;
	}


	public void setUserId(String userId) {
		this.userId = userId;
	}


	public Date getPostedTime() {
		return postedTime;
	}


	public void setPostedTime(Date postedTime) {
		this.postedTime = postedTime;
	}


	public String getStatus() {
		return status;
	}


	public void setStatus(String status) {
		this.status = status;
	}


	public String getFilePath() {
		return filePath;
	}


	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}


	public String getSourceType() {
		return sourceType;
	}


	public void setSourceType(String sourceType) {
		this.sourceType = sourceType;
	}


	public String getYunType() {
		return yunType;
	}


	public void setYunType(String yunType) {
		this.yunType = yunType;
	}


	public String getPlatformCode() {
		return platformCode;
	}


	public void setPlatformCode(String platformCode) {
		this.platformCode = platformCode;
	}


	public String getApplyType() {
		return applyType;
	}


	public void setApplyType(String applyType) {
		this.applyType = applyType;
	}


	public String getUploadId() {
		return uploadId;
	}


	public void setUploadId(String uploadId) {
		this.uploadId = uploadId;
	}


	public String getFileExtType() {
		if(Consts.docList.contains(getFileExt().toLowerCase())) {
			return "doc";
		}else if(Consts.picList.contains(getFileExt().toLowerCase())) {
			return "pic";
		}else if(Consts.audioList.contains(getFileExt().toLowerCase())) {
			return "audio";
		}else if(Consts.videoList.contains(getFileExt().toLowerCase())) {
			return "video";
		}else {
			return "other";
		}
	}


	public void setFileExtType(String fileExtType) {
		this.fileExtType = fileExtType;
	}


	public String getDownloadUrl() {
		return downloadUrl;
	}


	public void setDownloadUrl(String downloadUrl) {
		this.downloadUrl = downloadUrl;
	}


	public String getPreviewUrl() {
		return previewUrl;
	}


	public void setPreviewUrl(String previewUrl) {
		this.previewUrl = previewUrl;
	}


	public String getBucketName() {
		return bucketName;
	}


	public void setBucketName(String bucketName) {
		this.bucketName = bucketName;
	}


	public String getTransformStutas() {
		return transformStutas;
	}


	public void setTransformStutas(String transformStutas) {
		this.transformStutas = transformStutas;
	}


	public String getTransformId() {
		return transformId;
	}


	public void setTransformId(String transformId) {
		this.transformId = transformId;
	}


	public String getDuration() {
		return duration;
	}


	public void setDuration(String duration) {
		this.duration = duration;
	}

	public String getThumbnailUrl() {
		return thumbnailUrl;
	}


	public void setThumbnailUrl(String thumbnailUrl) {
		this.thumbnailUrl = thumbnailUrl;
	}

	public String getTransFileLength() {
		return transFileLength;
	}

	public void setTransFileLength(String transFileLength) {
		this.transFileLength = transFileLength;
	}

	public String getThumbnailId() {
		return thumbnailId;
	}

	public void setThumbnailId(String thumbnailId) {
		this.thumbnailId = thumbnailId;
	}
	
	
    
}
